<?php
require_once dirname(__FILE__)."/../SMSService.php";
require_once dirname(__FILE__)."/../../ApplicationException.php";
require_once dirname(__FILE__)."/../../model/SMS.php";

class SMSServiceImpl implements SMSService {

    public function __construct() {
        $this->smsDAO = new SMSSQLDAOImpl();
    }

    private $smsDAO;

    public function add(SMS $sms) {
        try {
            $this->smsDAO->create($sms);
        } catch (DataAccessException $e) {
            throw new ApplicationException($e->getMessage());
        }
    }

    public function getById($id) {
        try {
            return $this->smsDAO->read($id);
        } catch (DataAccessException $e) {
            throw new ApplicationException($e->getMessage());
        }
    }

    public function getSMSByUserId($id) {
        try {
            return $this->smsDAO->getSMSByUserId($id);
        } catch (DataAccessException $e) {
            throw new ApplicationException($e->getMessage());
        }
    }
    
    public function getSMSByStatus($status, $userId) {
        try {
            return $this->smsDAO->getSMSByStatus($status, $userId);
        } catch (DataAccessException $e) {
            throw new ApplicationException($e->getMessage());
        }
    }

    public function update(SMS $sms) {
        try {
            $this->smsDAO->update($sms);
        } catch (DataAccessException $e) {
            throw new ApplicationException($e->getMessage());
        }
    }

    public function deleteById($id) {
        try {
            $this->smsDAO->delete($id);
        } catch (DataAccessException $e) {
            throw new ApplicationException($e->getMessage());
        }
    }

    public function send(SMS $sms) {
        
    }
    
}
?>
